﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace JibberJabber.Controls
{
    public class XmlAttributeTextBox : TextBox
    {
        public XmlAttributeTextBox()
            : base()
        {
            this.TextChanged += new EventHandler(XmlAttributeTextBox_TextChanged);
        }

        void XmlAttributeTextBox_TextChanged(object sender, EventArgs e)
        {
            if (Text.Contains('"') || Text.Contains('>') || Text.Contains('<'))
            {
                MessageBox.Show("Please avoid the \", < and > characters.",
                    "Invalid characters", MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                Text = Text.Replace('"', '\'').Replace('<', '[')
                    .Replace('>', ']');
            }
        }
    }
}
